#include<bits/stdc++.h>
using namespace std;
 
int n(string a,string b,string c,string f,string e){
    int res=0;
    int d[5];
     
    d[0]=a[0]-'0';
    d[1]=b[0]-'0';
    d[2]=c[0]-'0';
    d[3]=f[0]-'0';
    d[4]=e[0]-'0';
    for(int i=0;i<5;i++){
        if(d[i]=='A'-'0'){
            d[i]=14;
        }else if(d[i]=='T'-'0'){
            d[i]=10;
        }else if(d[i]=='J'-'0'){
            d[i]=11;
        }else if(d[i]=='Q'-'0'){
            d[i]=12;
        }else if(d[i]=='K'-'0'){
            d[i]=13;
        }
    }
     
    sort(d,d+5);
     
    if( a[1]==b[1]
    &&b[1]==c[1]
    &&c[1]==f[1]
    &&f[1]==e[1]
    &&d[0]+1==d[1]&&d[1]+1==d[2]&&d[2]+1==d[3]&&d[3]+1==d[4]){
        res+=900000000;
        return res+d[4]; 
    }
     
     
     
    else if(d[0]==d[1]&&d[1]==d[2]&&d[2]==d[3]
    ||
    d[1]==d[2]&&d[2]==d[3]&&d[3]==d[4]
    ){
        res+=800000000;
        return res+d[1];
    }
     
     
    else if(d[0]==d[1]&&d[1]==d[2] && d[3]==d[4]
    ||
    d[1]==d[2]&&d[2]==d[3] && d[0]==d[4]
    ||
    d[2]==d[3]&&d[3]==d[4] && d[0]==d[1]){
        res+=700000000;
        return res+d[2];
    }
     
    else if(a[1]==b[1]
    &&b[1]==c[1]
    &&c[1]==f[1]
    &&f[1]==e[1]){
        res+=600000000;
        return res+d[4]*160000+d[3]*8000+d[2]*400+d[1]*20+d[0];
    }
     
    else if(d[0]+1==d[1]&&d[1]+1==d[2]&&d[2]+1==d[3]&&d[3]+1==d[4]){
        res+=500000000;
        return res+d[4];
         
         
    }else if(d[0]==d[1]&&d[1]==d[2] 
    ||
    d[1]==d[2]&&d[2]==d[3] 
    ||
    d[2]==d[3]&&d[3]==d[4] ){
        res+=400000000;
        return res+d[2];
    }
     
     
     
     
    else if(d[0]==d[1]&&d[2]==d[3]
    ||
    d[0]==d[1]&&d[3]==d[4]
    ||
    d[1]==d[2]&&d[3]==d[4]
    ){
        res+=300000000;
        if(d[0]==d[1]&&d[2]==d[3]){
            return res+d[3]*40000+d[0]*200+d[4];
        }else if(d[0]==d[1]&&d[3]==d[4]){
            return res+d[3]*40000+d[0]*200+d[2];
        }else{
            return res+d[3]*40000+d[1]*200+d[0];
        }
         
         
    }else if(d[0]==d[1]||d[1]==d[2]||d[2]==d[3]||d[3]==d[4]){
        res+=200000000;
        if(d[0]==d[1]){
            return res+d[0]*160000+d[4]*8000+d[3]*400+d[2]*20;
        }else if(d[1]==d[2]){
            return res+d[1]*160000+d[4]*8000+d[3]*400+d[0]*20;
        }else if(d[2]==d[3]){
            return res+d[2]*160000+d[4]*8000+d[1]*400+d[0]*20;
        }else if(d[3]==d[4]){
            return res+d[3]*160000+d[2]*8000+d[1]*400+d[0]*20;
        }
    }else{
        return d[4]*160000+d[3]*8000+d[2]*400+d[1]*20+d[0];
    }
     
}
int main(){ 
    string s[10];
    while(cin>>s[0]>>s[1]>>s[2]>>s[3]>>s[4]>>s[5]>>s[6]>>s[7]>>s[8]>>s[9]){
        int a=n(s[0],s[1],s[2],s[3],s[4]);
        int b=n(s[5],s[6],s[7],s[8],s[9]);
        if(a==b){
            cout<<"Tie.\n";
        }else if(a>b){
            cout<<"Black wins.\n";
        }else{
            cout<<"White wins.\n";
        }
    }
    return 0;
}

